package com.fengniaoxls.fengniaonewretail.net.resonse;


import android.content.Intent;

import com.fengniaoxls.fengniaonewretail.app.App;
import com.freak.httphelper.ApiException;
import com.freak.httphelper.log.LogUtil;


import io.reactivex.functions.Function;


/**
 * 此方法是接口返回数据的解析
 *
 * @author freak
 * @date 2019/9/11.
 */
public class HttpResultFunc<T> implements Function<HttpResult<T>, T> {
    @Override
    public T apply(HttpResult<T> tHttpResult) throws Exception {
        if (tHttpResult.getCode() == 200) {
            return tHttpResult.getData();
        } else if (tHttpResult.getCode() == 706) {
            throw new ApiException(tHttpResult.getMsg());
        } else if (tHttpResult.getCode() == 708) {

            throw new ApiException(tHttpResult.getMsg());
        } else {
            throw new ApiException(tHttpResult.getMsg());
        }
    }
}
